package com.hs.global.action;
 
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.hs.auth.model.HsAccount;
import com.hs.auth.model.HsUserinfo;
import com.hs.core.action.BaseAction;
@Controller  
public class IndexController  extends BaseAction {
    /**
	 * 
	 */
	private static final long serialVersionUID = -354434172898440670L;
	private static final Logger logger = Logger.getLogger(IndexController.class);
	 
	 /**
	  * 菜单控制
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/menu.do", method = RequestMethod.GET)   
     public ModelAndView indexMenu(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
		 HsAccount acc = this.getCurrentuser(request);
         String userName = "";
         if(null != acc){
	         HsUserinfo userinfo = acc.getUserinfo();
	         if(null != userinfo){
	        	 userName = userinfo.getUsername();
	         }
         }
         modelMap.put("username", userName);
		 return new ModelAndView("app/menu",modelMap);
		 
	 } 
	 /**
	  * 主要header
	  * @param request
	  * @param response
	  * @param modelMap
	  * @return
	  * @throws ServletException
	  * @throws IOException
	  */
	 @RequestMapping(value="/header.do", method = RequestMethod.GET)   
     public ModelAndView indexHeader(HttpServletRequest request,
				HttpServletResponse response,ModelMap modelMap) throws ServletException, IOException {
        
		 return new ModelAndView("app/head",modelMap);
		 
	 } 
}
